package com.blac.utils

import android.content.Context
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import java.lang.ref.WeakReference

object ToastUtil {

    private var mContext:WeakReference<Context>?=null
    private val handle = Handler(Looper.getMainLooper())

    fun init(context: Context){
        mContext=WeakReference(context.applicationContext)
    }

    fun showToast(message:String){
        mContext?.get()?:return

        handle.post {
            mContext?.get()?.let {
                Toast.makeText(it,message,Toast.LENGTH_SHORT).show()
            }
        }

    }
}